function efficiencyRoundTrip_cost = functionBPTES_eta(x, constX)
    powerNominalCharge = constX(1);
    chargingHours = constX(2);
    UA_Reg = x(1);
    UA_Hot = x(2);
    UA_Cold = x(3);
    T1Charge = x(4);
    T4Charge = x(5);
    T1Discharge = x(6);
    T4Discharge = x(7);
    pressureRatio = x(8);
    capacityMassGain = x(9);
    
    BPTESobj = BPTES(powerNominalCharge, chargingHours, UA_Reg, UA_Hot, UA_Cold, T1Charge, T4Charge, T1Discharge, T4Discharge, pressureRatio, capacityMassGain);

    % % 记录储热变化
    % massSaltHot1RatioList = [];
    % massSaltHot2RatioList = [];
    % massSaltCold1RatioList = [];
    % massSaltCold2RatioList = [];
    
    % 添加内部约束
    if (BPTESobj.T2Charge > BPTESobj.T5Charge) && ...
       (BPTESobj.T2Discharge > BPTESobj.T5Discharge) && ...
       (BPTESobj.T6Charge - BPTESobj.T2Charge >= BPTESobj.pinchpointReg) && ...
       (BPTESobj.T5Charge - BPTESobj.T3Charge >= BPTESobj.pinchpointReg) && ...
       (BPTESobj.T2Discharge - BPTESobj.T6Discharge >= BPTESobj.pinchpointReg) && ...
       (BPTESobj.T3Discharge - BPTESobj.T5Discharge >= BPTESobj.pinchpointReg) % 以上为回热需要满足的约束

        powerChargeList = [];
        powerDischargeList = [];

        BPTESobj.massSaltHot1 = 0.1.* BPTESobj.capacityEnergy ./ (BPTESobj.T1SaltHot - BPTESobj.T2SaltHot) ./ BPTESobj.c_pSaltHot .* (1 + BPTESobj.capacityMassGain) +0.1 ; % 热罐1质量
        BPTESobj.massSaltHot2 = 0.9.* BPTESobj.capacityEnergy ./ (BPTESobj.T1SaltHot - BPTESobj.T2SaltHot) ./ BPTESobj.c_pSaltHot .* (1 + BPTESobj.capacityMassGain) -0.1; 
        BPTESobj.massSaltCold1 = 0.9.* BPTESobj.capacityEnergy ./ (BPTESobj.T1SaltCold - BPTESobj.T2SaltCold) ./ BPTESobj.c_pSaltCold .* (1 - BPTESobj.capacityMassGain) -0.1; 
        BPTESobj.massSaltCold2 = 0.1.* BPTESobj.capacityEnergy ./ (BPTESobj.T1SaltCold - BPTESobj.T2SaltCold) ./ BPTESobj.c_pSaltCold .* (1 - BPTESobj.capacityMassGain) +0.1; 

        massSaltHot1_0 = BPTESobj.massSaltHot1; % 保存初始热罐1质量

        % % 记录储热变化
        % massSaltHot1RatioList = [massSaltHot1RatioList, BPTESobj.massSaltHot1Ratio];
        % massSaltHot2RatioList = [massSaltHot2RatioList, BPTESobj.massSaltHot2Ratio];
        % massSaltCold1RatioList = [massSaltCold1RatioList, BPTESobj.massSaltCold1Ratio];
        % massSaltCold2RatioList = [massSaltCold2RatioList, BPTESobj.massSaltCold2Ratio];

        while true % 充电
            powerAim = - powerNominalCharge; 
            powerReal = BPTESobj.chargeORdischarge(powerAim); % 注意此处出来是负数
            powerChargeList = [powerChargeList, abs(powerReal)];

            % % 记录储热变化
            % massSaltHot1RatioList = [massSaltHot1RatioList, BPTESobj.massSaltHot1Ratio];
            % massSaltHot2RatioList = [massSaltHot2RatioList, BPTESobj.massSaltHot2Ratio];
            % massSaltCold1RatioList = [massSaltCold1RatioList, BPTESobj.massSaltCold1Ratio];
            % massSaltCold2RatioList = [massSaltCold2RatioList, BPTESobj.massSaltCold2Ratio];

            if abs(powerReal) < 1
                break;
            end
        end

        deltaEnergySaltHot = (BPTESobj.massSaltHot1 - massSaltHot1_0).*(BPTESobj.T1SaltHot - BPTESobj.T2SaltHot) .* BPTESobj.c_pSaltHot;
        efficencyCharge = deltaEnergySaltHot./(sum(powerChargeList).*BPTESobj.timeStep); % 充电效率，以热罐为基准

        % 放电准备
        BPTESobj.massSaltHot1 = 0.9.* BPTESobj.capacityEnergy ./ (BPTESobj.T1SaltHot - BPTESobj.T2SaltHot) ./ BPTESobj.c_pSaltHot .* (1 + BPTESobj.capacityMassGain) -1; % 热罐1质量
        BPTESobj.massSaltHot2 = 0.1.* BPTESobj.capacityEnergy ./ (BPTESobj.T1SaltHot - BPTESobj.T2SaltHot) ./ BPTESobj.c_pSaltHot .* (1 + BPTESobj.capacityMassGain) +1 ; 
        BPTESobj.massSaltCold1 = 0.1.* BPTESobj.capacityEnergy ./ (BPTESobj.T1SaltCold - BPTESobj.T2SaltCold) ./ BPTESobj.c_pSaltCold .* (1 - BPTESobj.capacityMassGain) +1; 
        BPTESobj.massSaltCold2 = 0.9.* BPTESobj.capacityEnergy ./ (BPTESobj.T1SaltCold - BPTESobj.T2SaltCold) ./ BPTESobj.c_pSaltCold .* (1 - BPTESobj.capacityMassGain) -1; 

        massSaltHot2_0 = BPTESobj.massSaltHot2; % 保存初始热罐2质量

        % % 记录储热变化
        % massSaltHot1RatioList = [massSaltHot1RatioList, BPTESobj.massSaltHot1Ratio];
        % massSaltHot2RatioList = [massSaltHot2RatioList, BPTESobj.massSaltHot2Ratio];
        % massSaltCold1RatioList = [massSaltCold1RatioList, BPTESobj.massSaltCold1Ratio];
        % massSaltCold2RatioList = [massSaltCold2RatioList, BPTESobj.massSaltCold2Ratio];

        while true % 放电
            powerAim = powerNominalCharge;
            powerReal = BPTESobj.chargeORdischarge(powerAim);
            powerDischargeList = [powerDischargeList, abs(powerReal)];
            
            % % 记录储热变化
            % massSaltHot1RatioList = [massSaltHot1RatioList, BPTESobj.massSaltHot1Ratio];
            % massSaltHot2RatioList = [massSaltHot2RatioList, BPTESobj.massSaltHot2Ratio];
            % massSaltCold1RatioList = [massSaltCold1RatioList, BPTESobj.massSaltCold1Ratio];
            % massSaltCold2RatioList = [massSaltCold2RatioList, BPTESobj.massSaltCold2Ratio];

            if abs(powerReal) < 1
                break;
            end
        end

        deltaEnergySaltHot = (BPTESobj.massSaltHot2 - massSaltHot2_0).*(BPTESobj.T1SaltHot - BPTESobj.T2SaltHot) .* BPTESobj.c_pSaltHot;
        efficencyDischarge = (sum(powerDischargeList).*BPTESobj.timeStep)./deltaEnergySaltHot; % 放电效率，以热罐为基准

        efficiencyRoundTrip = efficencyDischarge * efficencyCharge * (-1); % round trip efficiency

        EUR2USD = 1.14; % 欧元对美元的汇率，假设为1.14，2024年
        cost_kWh = BPTESobj.investCostTotal./(BPTESobj.capacityEnergy./3600./1e3).*EUR2USD;
        costTotal = BPTESobj.investCostTotal.*EUR2USD;
    else
        efficiencyRoundTrip = 1;
        cost_kWh = inf;
        costTotal = inf;
    end


    % debug所用代码
    if ~isreal(cost_kWh)
        disp('cost_kWh是复数');
        disp(BPTESobj);
    elseif ~isreal(efficiencyRoundTrip)
        disp('efficiencyRoundTrip是复数');
        disp(BPTESobj);
    end

    % efficiencyRoundTrip_cost_kWh = [efficiencyRoundTrip, cost_kWh];
    efficiencyRoundTrip_cost = [efficiencyRoundTrip, costTotal]; % 总价格模式，原文献采用

    % % 记录储热变化
    % hold on;
    % plot(massSaltHot1RatioList, 'r', 'LineWidth', 1.5) % massTankHot1
    % plot(massSaltHot2RatioList, 'Color', [1 0.5 0], 'LineWidth', 1.5) % massTankHot2
    % plot(massSaltCold1RatioList, 'c', 'LineWidth', 1.5) % massTankCold1
    % plot(massSaltCold2RatioList, 'b', 'LineWidth', 1.5) % massTankCold2
    % hold off;
    % grid on;
    % % xlim([0,54])
    % legend('massTankHot1', 'massTankHot2', 'massTankCold1', 'massTankCold2');




    % 温熵图验证绘制
    % temperatureChargeArray = [BPTESobj.T1Charge, BPTESobj.T2Charge, BPTESobj.T3Charge, BPTESobj.T4Charge, BPTESobj.T5Charge, BPTESobj.T6Charge] - 273.15;
    % entropyBase = 0;
    % entropyChargeArray = [entropyBase, entropyBase, entropyBase+BPTESobj.c_pCycle*log(BPTESobj.T3Charge/BPTESobj.T2Charge), entropyBase+BPTESobj.c_pCycle*log(BPTESobj.T4Charge/BPTESobj.T2Charge), entropyBase+BPTESobj.c_pCycle*log(BPTESobj.T4Charge/BPTESobj.T2Charge), entropyBase+BPTESobj.c_pCycle*log(BPTESobj.T6Charge/BPTESobj.T1Charge)];

    % plot(entropyChargeArray,temperatureChargeArray, 'ro-');
    % hold on;
    % plot([entropyChargeArray(1),entropyChargeArray(end)],[temperatureChargeArray(1),temperatureChargeArray(end)], 'r-');

    % temperatureDischargeArray = [BPTESobj.T1Discharge, BPTESobj.T2Discharge, BPTESobj.T3Discharge, BPTESobj.T4Discharge, BPTESobj.T5Discharge, BPTESobj.T6Discharge] - 273.15;
    % entropyBase_discharge = entropyBase + BPTESobj.c_pCycle*log(BPTESobj.T1Discharge/BPTESobj.T1Charge);

    % entropyDischargeArray = [entropyBase_discharge,entropyBase_discharge,...
    %     entropyBase_discharge+BPTESobj.c_pCycle*log(BPTESobj.T3Discharge/BPTESobj.T2Discharge),...
    %     entropyBase_discharge+BPTESobj.c_pCycle*log(BPTESobj.T4Discharge/BPTESobj.T2Discharge),...
    %     entropyBase_discharge+BPTESobj.c_pCycle*log(BPTESobj.T4Discharge/BPTESobj.T2Discharge),...
    %     entropyBase_discharge+BPTESobj.c_pCycle*log(BPTESobj.T6Discharge/BPTESobj.T1Discharge)];

    % plot(entropyDischargeArray,temperatureDischargeArray, 'bo-');

    % text(entropyDischargeArray, temperatureDischargeArray, arrayfun(@num2str, 1:6, 'UniformOutput', false), 'VerticalAlignment', 'bottom', 'HorizontalAlignment', 'right');

    % text(entropyChargeArray, temperatureChargeArray, arrayfun(@num2str, 1:6, 'UniformOutput', false), 'VerticalAlignment', 'bottom', 'HorizontalAlignment', 'right');

    % hold on;
    % plot([entropyDischargeArray(1),entropyDischargeArray(end)],[temperatureDischargeArray(1),temperatureDischargeArray(end)], 'b-');

    % legend('charge','', 'discharge','','Location','northwest');


end